<script type="text/javascript">
//<![CDATA[
	(function() {
		var rootTc#session.module_id = new Ext.tree.TreeNode();
		var r = rootTc#session.module_id;
		Ext.getCmp("portlet_content_tc_<%=$_GET['module_id']%>").add(
			new Ext.Panel({
				layout: "border",
				items: [
					new Ext.tree.TreePanel({
						root: r,
						rootVisible: false,
						region: "west",
						width: 200,
						autoScroll: true,
						split: true,
						id: "tc_#session.module_id_tree",
						tbar: [{
							xtype: "button",
							text: "Add",
							iconCls: "add",
							handler: function(e) {
								Builder.editTestcase({id: "c_0"}, "#session.module_id");
							}
						},"-",{
							xtype: "button",
							text: "Delete",
							iconCls: "delete",
							handler: function(e) {
								Builder.delTestcase(Ext.getCmp("tc_#session.module_id_tree").getSelectionModel().getSelectedNode(), "#session.module_id");
							}
						}, "-"],
						listeners: {
							dblclick: function(n) {
								Builder.editTestcase(n, "#session.module_id");
							},
							contextmenu: function(n, e) {
								e.preventDefault();
								var menu = new Ext.menu.Menu({
									items: [{
										text: "Edit Testcase",
										iconCls: "edit",
										handler: function() {
											Builder.editTestcase(n, "#session.module_id");
											this.hide();
										}
									},{
										text: "Delete Testcase",
										iconCls: "delete",
										handler: function() {
											Builder.delTestcase(n, "#session.module_id");
											this.hide();
										}
									}]
								}).showAt(e.getXY());	
							}
						}										
					}),
					new Ext.Panel({
						region: "center",
						layout: "fit",
						autoScroll: true,
						id: "tc_#session.module_id_container",
						tbar: new Ext.Toolbar()
					})
				]
			})
		);
		Ext.getCmp("portlet_content_tc_#session.module_id").doLayout();
		
		<c:foreach var="testsuite" name="testcase">
			c = new Ext.tree.TreeNode({
				text: "#testcase.name",
				leaf: true,
				iconCls: "testcase",
				id: "c_#testcase.testcase_id",
				allowChildren: false
			});
			r.appendChild(c);
		</c:foreach>
	})();
//]]>
</script>
